Skip to content

Conversation

@acabarbaye
Copy link
Contributor

Description

fix problem we see with clients when upgrading APIs

Test Coverage

  • This change is covered by existing or additional automated tests.
  • Manual testing has been performed (and evidence provided) as automated testing was not feasible.
  • Additional tests are not required for this change (e.g. documentation update).

}

func checkResponseMarshalling(ctx context.Context, apiErr error, resp *http.Response, result any) (err error) {
if apiErr != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is going to be its own function then you should check the statuscode too, before it was after something that did that so we knew it would be successful but here we don't and it could cause confusion if someone uses the function elsewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a private function though

Comment on lines 112 to 125
// At this point, the marshalling problem may be due to the present of unknown fields in the response due to an API extension.
// See https://github.com/OpenAPITools/openapi-generator/issues/21446
var respB []byte
respB, err = safeio.ReadAll(ctx, resp.Body)
if err != nil {
return
}
_, err = marshmallow.Unmarshal(respB, result, marshmallow.WithSkipPopulateStruct(false), marshmallow.WithExcludeKnownFieldsFromMap(true))
if err != nil {
err = commonerrors.WrapError(commonerrors.ErrMarshalling, err, "API call was successful but an error occurred during response marshalling")
return
}
}
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you do this I think the function needs to have a different name since it isn't just checking, it is also doing another unmarshal attempt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough

Copy link
Contributor

@joshjennings98 joshjennings98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two comments but I think it will help a lot

@acabarbaye acabarbaye merged commit 152e9dc into main Jun 26, 2025
4 checks passed
@acabarbaye acabarbaye deleted the fix-unmarshalling branch June 26, 2025 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants